home *** CD-ROM | disk | FTP | other *** search
- Subject: v02i006: calentool - patch level 5, Part 4/4
- Newsgroups: comp.sources.sun
- Approved: mcgrew@aramis.rutgers.edu
-
- Submitted-by: Bill Randle <billr@saab.cna.tek.com>
- Posting-number: Volume 2, Issue 6
- Archive-name: calentool/patch5d
-
-
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 4 (of 4)."
- # Contents: patches05d
- # Wrapped by billr@saab on Tue Dec 19 11:47:41 1989
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'patches05d' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'patches05d'\"
- else
- echo shar: Extracting \"'patches05d'\" \(51460 characters\)
- sed "s/^X//" >'patches05d' <<'END_OF_FILE'
- X*** /tmp/,RCSt1a02457 Tue Dec 19 11:34:42 1989
- X--- utils.c Tue Dec 19 11:34:15 1989
- X***************
- X*** 1,5
- X /*
- X! * $Header: utils.c,v 2.3 89/07/19 20:31:40 billr Exp $
- X */
- X /*
- X * utils.c
- X
- X--- 1,5 -----
- X /*
- X! * $Header: utils.c,v 2.5 89/12/19 11:33:44 billr Exp $
- X */
- X /*
- X * utils.c
- X***************
- X*** 22,27
- X * Permission is hereby granted to use and modify the modifications in source
- X * or binary form as long as they are not sold for profit and this copyright
- X * notice remains intact.
- X */
- X /********************************************
- X * *
- X
- X--- 22,29 -----
- X * Permission is hereby granted to use and modify the modifications in source
- X * or binary form as long as they are not sold for profit and this copyright
- X * notice remains intact.
- X+ * Modified parse_date to allow +nnn and -nnn syntax for dates relative to the
- X+ * current date. Peter Marshall <peter.marshall@uwo.ca>. 1989-09-19.
- X */
- X /********************************************
- X * *
- X***************
- X*** 33,38
- X
- X #include "ct.h"
- X #include <stdio.h>
- X #include <suntool/sunview.h>
- X #include <suntool/canvas.h>
- X #include <ctype.h>
- X
- X--- 35,41 -----
- X
- X #include "ct.h"
- X #include <stdio.h>
- X+ #ifndef NOTOOL
- X #include <suntool/sunview.h>
- X #include <suntool/canvas.h>
- X #endif /* NOTOOL */
- X***************
- X*** 35,40
- X #include <stdio.h>
- X #include <suntool/sunview.h>
- X #include <suntool/canvas.h>
- X #include <ctype.h>
- X #include <sys/types.h>
- X #include <sys/file.h>
- X
- X--- 38,44 -----
- X #ifndef NOTOOL
- X #include <suntool/sunview.h>
- X #include <suntool/canvas.h>
- X+ #endif /* NOTOOL */
- X #include <ctype.h>
- X #include <sys/types.h>
- X #include <sys/time.h>
- X***************
- X*** 37,42
- X #include <suntool/canvas.h>
- X #include <ctype.h>
- X #include <sys/types.h>
- X #include <sys/file.h>
- X #include <sys/stat.h>
- X #include <sys/errno.h>
- X
- X--- 41,47 -----
- X #endif /* NOTOOL */
- X #include <ctype.h>
- X #include <sys/types.h>
- X+ #include <sys/time.h>
- X #include <sys/file.h>
- X #include <sys/stat.h>
- X #include <sys/errno.h>
- X***************
- X*** 54,60
- X extern int one_based, version2, new_entry;
- X extern int findex;
- X extern struct appt_entry future[];
- X- extern char todays_date[];
- X extern char apts_dir[], lib_dir[];
- X extern char printer[];
- X extern int include_old, save_old;
- X
- X--- 59,64 -----
- X extern int one_based, version2, new_entry;
- X extern int findex;
- X extern struct appt_entry future[];
- X extern char apts_dir[], lib_dir[];
- X extern int include_old, save_old, expire_days;
- X #ifndef NOTOOL
- X***************
- X*** 56,61
- X extern struct appt_entry future[];
- X extern char todays_date[];
- X extern char apts_dir[], lib_dir[];
- X extern char printer[];
- X extern int include_old, save_old;
- X extern Frame frame;
- X
- X--- 60,67 -----
- X extern int findex;
- X extern struct appt_entry future[];
- X extern char apts_dir[], lib_dir[];
- X+ extern int include_old, save_old, expire_days;
- X+ #ifndef NOTOOL
- X extern char printer[];
- X extern Frame frame;
- X extern Canvas canvas;
- X***************
- X*** 57,63
- X extern char todays_date[];
- X extern char apts_dir[], lib_dir[];
- X extern char printer[];
- X- extern int include_old, save_old;
- X extern Frame frame;
- X extern Canvas canvas;
- X extern Pixwin *main_pixwin;
- X
- X--- 63,68 -----
- X extern int include_old, save_old, expire_days;
- X #ifndef NOTOOL
- X extern char printer[];
- X extern Frame frame;
- X extern Canvas canvas;
- X extern Pixwin *main_pixwin;
- X***************
- X*** 65,70
- X extern Pixfont *font, *sfont;
- X extern Frame prompt_frame;
- X extern int update_interval;
- X extern int errno;
- X
- X char inbuf[512], strbuf[256], errbuf[64];
- X
- X--- 70,77 -----
- X extern Pixfont *font, *sfont;
- X extern Frame prompt_frame;
- X extern int update_interval;
- X+ extern int monday_first, hour24, day_first;
- X+ #endif /* NOTOOL */
- X extern int errno;
- X
- X char inbuf[512], strbuf[256], errbuf[128];
- X***************
- X*** 67,75
- X extern int update_interval;
- X extern int errno;
- X
- X! char inbuf[512], strbuf[256], errbuf[64];
- X! char todays_date[32];
- X! static int including;
- X static int log_to_console;
- X char *daynames[] = {"Sunday","Monday","Tuesday","Wednesday",
- X "Thursday","Friday","Saturday"};
- X
- X--- 74,82 -----
- X #endif /* NOTOOL */
- X extern int errno;
- X
- X! char inbuf[512], strbuf[256], errbuf[128];
- X! char clockstr[32];
- X! static int include_level = 0;
- X static int log_to_console;
- X char *daynames[] = {"Sunday","Monday","Tuesday","Wednesday",
- X "Thursday","Friday","Saturday"};
- X***************
- X*** 76,81
- X char *monthnames[] = {"January","February","March","April",
- X "May","June","July","August",
- X "September","October","November","December"};
- X char *dayname[7] = {"SU", "MO", "TU", "WE", "TH", "FR", "SA"};
- X char rasfile[] = "/usr/tmp/calentool.ras";
- X char psfile[] = "/usr/tmp/calentool.ps";
- X
- X--- 83,91 -----
- X char *monthnames[] = {"January","February","March","April",
- X "May","June","July","August",
- X "September","October","November","December"};
- X+ char *smonthnames[] = {"Jan","Feb","Mar","Apr",
- X+ "May","Jun","Jul","Aug",
- X+ "Sep","Oct","Nov","Dec"};
- X char *dayname[7] = {"SU", "MO", "TU", "WE", "TH", "FR", "SA"};
- X char rasfile[] = "/usr/tmp/calentool.ras";
- X char psfile[] = "/usr/tmp/calentool.ps";
- X***************
- X*** 91,96
- X {
- X struct tm *tm;
- X struct timeval tv;
- X
- X gettimeofday(&tv, 0);
- X tm = localtime(&tv.tv_sec);
- X
- X--- 101,107 -----
- X {
- X struct tm *tm;
- X struct timeval tv;
- X+ char timstr[16];
- X
- X gettimeofday(&tv, 0);
- X tm = localtime(&tv.tv_sec);
- X***************
- X*** 97,103
- X
- X today = *tm;
- X
- X! strcpy(todays_date, asctime(tm));
- X if (update_interval >= 60)
- X /* overwrite seconds field with year */
- X sprintf(&todays_date[16], " %d", today.tm_year+1900);
- X
- X--- 108,120 -----
- X
- X today = *tm;
- X
- X! #ifndef CALENCHECK
- X! if (day_first)
- X! sprintf(clockstr, "%3.3s %d %s %d, ", daynames[today.tm_wday],
- X! today.tm_mday, smonthnames[today.tm_mon], today.tm_year+1900);
- X! else
- X! sprintf(clockstr, "%3.3s %s %d %d, ", daynames[today.tm_wday],
- X! smonthnames[today.tm_mon], today.tm_mday, today.tm_year+1900);
- X if (update_interval >= 60)
- X sprintf(timstr, "%02d:%02d", today.tm_hour, today.tm_min);
- X else
- X***************
- X*** 99,106
- X
- X strcpy(todays_date, asctime(tm));
- X if (update_interval >= 60)
- X! /* overwrite seconds field with year */
- X! sprintf(&todays_date[16], " %d", today.tm_year+1900);
- X else
- X /* just delete trailing \n */
- X todays_date[strlen(todays_date)-1] = '\0';
- X
- X--- 116,122 -----
- X sprintf(clockstr, "%3.3s %s %d %d, ", daynames[today.tm_wday],
- X smonthnames[today.tm_mon], today.tm_mday, today.tm_year+1900);
- X if (update_interval >= 60)
- X! sprintf(timstr, "%02d:%02d", today.tm_hour, today.tm_min);
- X else
- X sprintf(timstr, "%02d:%02d:%02d", today.tm_hour, today.tm_min, today.tm_sec);
- X if (!hour24) {
- X***************
- X*** 102,109
- X /* overwrite seconds field with year */
- X sprintf(&todays_date[16], " %d", today.tm_year+1900);
- X else
- X! /* just delete trailing \n */
- X! todays_date[strlen(todays_date)-1] = '\0';
- X }
- X
- X /*
- X
- X--- 118,140 -----
- X if (update_interval >= 60)
- X sprintf(timstr, "%02d:%02d", today.tm_hour, today.tm_min);
- X else
- X! sprintf(timstr, "%02d:%02d:%02d", today.tm_hour, today.tm_min, today.tm_sec);
- X! if (!hour24) {
- X! /* display am/pm for 12-hour time */
- X! if (today.tm_hour > 12) {
- X! strcat(timstr, "pm");
- X! timstr[0] = ((today.tm_hour - 12) / 10) + '0';
- X! timstr[1] = ((today.tm_hour - 12) % 10) + '0';
- X! } else if (today.tm_hour == 12) {
- X! strcat(timstr, "pm");
- X! } else {
- X! strcat(timstr, "am");
- X! }
- X! if (timstr[0] == '0')
- X! timstr[0] = ' ';
- X! }
- X! strcat(clockstr, timstr);
- X! #endif /* CALENCHECK */
- X }
- X
- X /*
- X***************
- X*** 140,169
- X current.tm_year++;
- X }
- X }
- X! current.tm_yday = current.tm_mday - 1;
- X! for (month = 0; month < current.tm_mon; month++) {
- X! current.tm_yday += monthlength(month);
- X! }
- X! if ((current.tm_year < today.tm_year)
- X! || ((current.tm_year == today.tm_year)
- X! && (current.tm_yday < today.tm_yday))) {
- X! from = current;
- X! to = today;
- X! } else {
- X! from = today;
- X! to = current;
- X! }
- X! if (from.tm_year != to.tm_year) {
- X! for (totdays = 0; from.tm_year < to.tm_year; from.tm_year++)
- X! totdays += dysize(from.tm_year + 1900);
- X! }
- X! totdays += to.tm_yday - from.tm_yday;
- X! if ((current.tm_year < today.tm_year)
- X! || ((current.tm_year == today.tm_year)
- X! && (current.tm_yday < today.tm_yday)))
- X! totdays = -totdays;
- X! current.tm_wday =
- X! ((totdays % 7) + 7 + today.tm_wday) % 7;
- X }
- X
- X /*
- X
- X--- 171,178 -----
- X current.tm_year++;
- X }
- X }
- X! current.tm_yday = day_of_year((double)current.tm_mday, current.tm_mon+1, current.tm_year+1900);
- X! current.tm_wday = get_day_of_week((double)current.tm_mday, current.tm_mon+1, current.tm_year+1900);
- X }
- X
- X /*
- X***************
- X*** 188,194
- X {
- X static int monthlengths[] = {31,28,31,30,31,30,31,31,30,31,30,31};
- X
- X! if (month == FEB && (dysize(current.tm_year + 1900) == 366))
- X return(29);
- X else
- X return(monthlengths[month]);
- X
- X--- 197,203 -----
- X {
- X static int monthlengths[] = {31,28,31,30,31,30,31,31,30,31,30,31};
- X
- X! if (month == FEB && (length_of_year(current.tm_year + 1900) == 366))
- X return(29);
- X else
- X return(monthlengths[month]);
- X***************
- X*** 194,199
- X return(monthlengths[month]);
- X }
- X
- X /*
- X *
- X * Append data from active timeslots to end of "tmp.appointments"
- X
- X--- 203,209 -----
- X return(monthlengths[month]);
- X }
- X
- X+ #ifndef CALENCHECK
- X /*
- X *
- X * Append data from active timeslots to end of "tmp.appointments"
- X***************
- X*** 256,261
- X return(1);
- X xrename(tmpapts_pathname, apts_pathname);
- X }
- X
- X /*
- X * get entry from appointments file
- X
- X--- 266,272 -----
- X return(1);
- X xrename(tmpapts_pathname, apts_pathname);
- X }
- X+ #endif /* CALENCHECK */
- X
- X /*
- X * get entry from appointments file
- X***************
- X*** 260,266
- X /*
- X * get entry from appointments file
- X */
- X! get_aentry(apts_file, appt)
- X FILE *apts_file;
- X struct appt_entry *appt;
- X {
- X
- X--- 271,277 -----
- X /*
- X * get entry from appointments file
- X */
- X! get_aentry(apts_file, appt, noInclude)
- X FILE *apts_file;
- X struct appt_entry *appt;
- X int noInclude;
- X***************
- X*** 263,268
- X get_aentry(apts_file, appt)
- X FILE *apts_file;
- X struct appt_entry *appt;
- X {
- X char *ptr, *str;
- X char *fgets(), *index();
- X
- X--- 274,280 -----
- X get_aentry(apts_file, appt, noInclude)
- X FILE *apts_file;
- X struct appt_entry *appt;
- X+ int noInclude;
- X {
- X char *ptr, *str;
- X char *fgets(), *index();
- X***************
- X*** 267,273
- X char *ptr, *str;
- X char *fgets(), *index();
- X char *incl_ptr, incl_buf[128], wday[3];
- X! int i, lib;
- X struct stat sbuf;
- X static FILE *include;
- X
- X
- X--- 279,285 -----
- X char *ptr, *str;
- X char *fgets(), *index();
- X char *incl_ptr, incl_buf[128], wday[3];
- X! int i, lib, parse_options, nodata = 1;
- X struct stat sbuf;
- X static FILE *include[MAX_INCLUDE_NESTING];
- X
- X***************
- X*** 269,275
- X char *incl_ptr, incl_buf[128], wday[3];
- X int i, lib;
- X struct stat sbuf;
- X! static FILE *include;
- X
- X appt->flags = appt->repeat = appt->lookahead = 0;
- X appt->sindex = 0;
- X
- X--- 281,287 -----
- X char *incl_ptr, incl_buf[128], wday[3];
- X int i, lib, parse_options, nodata = 1;
- X struct stat sbuf;
- X! static FILE *include[MAX_INCLUDE_NESTING];
- X
- X appt->flags = appt->repeat = appt->lookahead = 0;
- X appt->sindex = 0;
- X***************
- X*** 273,278
- X
- X appt->flags = appt->repeat = appt->lookahead = 0;
- X appt->sindex = 0;
- X appt->next = NULL;
- X if (including) {
- X if (fgets(inbuf, 512, include) == NULL) {
- X
- X--- 285,291 -----
- X
- X appt->flags = appt->repeat = appt->lookahead = 0;
- X appt->sindex = 0;
- X+ appt->runlength = 0;
- X appt->next = NULL;
- X /* If noInclude is set then don't follow include files, i.e.
- X * treat #include directives as comments. This is useful for
- X***************
- X*** 274,286
- X appt->flags = appt->repeat = appt->lookahead = 0;
- X appt->sindex = 0;
- X appt->next = NULL;
- X! if (including) {
- X! if (fgets(inbuf, 512, include) == NULL) {
- X! /* end of include file - get next entry
- X! * from main file
- X! */
- X! including = 0;
- X! fclose(include);
- X if (fgets(inbuf, 512, apts_file) == NULL)
- X return(EOF);
- X } else {
- X
- X--- 287,310 -----
- X appt->sindex = 0;
- X appt->runlength = 0;
- X appt->next = NULL;
- X! /* If noInclude is set then don't follow include files, i.e.
- X! * treat #include directives as comments. This is useful for
- X! * copying the appts file.
- X! */
- X! while (nodata) {
- X! if (include_level) {
- X! if (fgets(inbuf, 512, include[include_level-1]) == NULL) {
- X! /* end of include file - get next entry
- X! * from previous level of nesting
- X! */
- X! fclose(include[include_level-1]);
- X! include_level--;
- X! } else {
- X! /* don't modify stuff from include files */
- X! appt->flags |= READONLY;
- X! nodata = 0; /* still data in file */
- X! }
- X! } else {
- X if (fgets(inbuf, 512, apts_file) == NULL)
- X return(EOF);
- X else
- X***************
- X*** 283,292
- X fclose(include);
- X if (fgets(inbuf, 512, apts_file) == NULL)
- X return(EOF);
- X! } else {
- X! including = 2;
- X! /* don't modify stuff from include files */
- X! appt->flags |= READONLY;
- X }
- X } else
- X if (fgets(inbuf, 512, apts_file) == NULL)
- X
- X--- 307,314 -----
- X } else {
- X if (fgets(inbuf, 512, apts_file) == NULL)
- X return(EOF);
- X! else
- X! nodata = 0; /* still data in file */
- X }
- X }
- X ptr = inbuf;
- X***************
- X*** 288,296
- X /* don't modify stuff from include files */
- X appt->flags |= READONLY;
- X }
- X! } else
- X! if (fgets(inbuf, 512, apts_file) == NULL)
- X! return(EOF);
- X ptr = inbuf;
- X if (*ptr == '#') {
- X if (!strcmp(inbuf, HEADER) && !including) {
- X
- X--- 310,316 -----
- X else
- X nodata = 0; /* still data in file */
- X }
- X! }
- X ptr = inbuf;
- X if (noInclude && *ptr == '#') {
- X appt->flags |= A_COMMENT;
- X***************
- X*** 292,297
- X if (fgets(inbuf, 512, apts_file) == NULL)
- X return(EOF);
- X ptr = inbuf;
- X if (*ptr == '#') {
- X if (!strcmp(inbuf, HEADER) && !including) {
- X /* first line in file read */
- X
- X--- 312,321 -----
- X }
- X }
- X ptr = inbuf;
- X+ if (noInclude && *ptr == '#') {
- X+ appt->flags |= A_COMMENT;
- X+ return(0);
- X+ }
- X if (*ptr == '#') {
- X if (!strcmp(inbuf, HEADER) && !include_level) {
- X /* first line in base file read */
- X***************
- X*** 293,300
- X return(EOF);
- X ptr = inbuf;
- X if (*ptr == '#') {
- X! if (!strcmp(inbuf, HEADER) && !including) {
- X! /* first line in file read */
- X if (include_old && (First.tm_year < today.tm_year)) {
- X /* read in old include file (if it exists) */
- X /* prepend directory info */
- X
- X--- 317,324 -----
- X return(0);
- X }
- X if (*ptr == '#') {
- X! if (!strcmp(inbuf, HEADER) && !include_level) {
- X! /* first line in base file read */
- X if (include_old && (First.tm_year < today.tm_year)) {
- X /* read in old include file (if it exists) */
- X /* prepend directory info */
- X***************
- X*** 301,310
- X sprintf(incl_buf, "%s/.appointments.%02d",
- X apts_dir, First.tm_year);
- X if (!stat(incl_buf, &sbuf)) {
- X! if ((include = fopen(incl_buf, "r")) == NULL)
- X! err_rpt("can't open include file (ignored)", NON_FATAL);
- X! else
- X! including = 1;
- X }
- X }
- X } else if (!strncmp(inbuf, "#include", 8)) {
- X
- X--- 325,337 -----
- X sprintf(incl_buf, "%s/.appointments.%02d",
- X apts_dir, First.tm_year);
- X if (!stat(incl_buf, &sbuf)) {
- X! if ((include[include_level] = fopen(incl_buf, "r")) == NULL) {
- X! strcpy(errbuf, "can't open include file <");
- X! strcat(errbuf, incl_buf);
- X! strcat(errbuf, "> (ignored)");
- X! err_rpt(errbuf, NON_FATAL);
- X! } else
- X! include_level++;
- X }
- X }
- X } else if (!strncmp(inbuf, "#include", 8)) {
- X***************
- X*** 309,316
- X }
- X } else if (!strncmp(inbuf, "#include", 8)) {
- X /* include file */
- X! if (including)
- X! err_rpt("include files may not be nested", FATAL);
- X incl_ptr = strbuf;
- X if ((ptr = index(inbuf, '"')) == NULL)
- X
- X
- X--- 336,346 -----
- X }
- X } else if (!strncmp(inbuf, "#include", 8)) {
- X /* include file */
- X! if (include_level > MAX_INCLUDE_NESTING) {
- X! err_rpt("include files nested too deep (ignored)", NON_FATAL);
- X! appt->flags |= A_COMMENT;
- X! return(0);
- X! }
- X incl_ptr = strbuf;
- X if ((ptr = index(inbuf, '"')) == NULL)
- X
- X***************
- X*** 316,321
- X
- X if ((ptr = index(inbuf, '<')) == NULL) {
- X err_rpt("missing '\"' or '<' in include file spec", NON_FATAL);
- X return(0);
- X } else {
- X lib = 1;
- X
- X--- 346,352 -----
- X
- X if ((ptr = index(inbuf, '<')) == NULL) {
- X err_rpt("missing '\"' or '<' in include file spec", NON_FATAL);
- X+ appt->flags |= A_COMMENT;
- X return(0);
- X } else {
- X lib = 1;
- X***************
- X*** 327,332
- X *incl_ptr++ = *ptr++;
- X if (! *ptr) {
- X err_rpt("missing '\"' or '>' in include file spec", NON_FATAL);
- X return(0);
- X }
- X *incl_ptr = '\0';
- X
- X--- 358,364 -----
- X *incl_ptr++ = *ptr++;
- X if (! *ptr) {
- X err_rpt("missing '\"' or '>' in include file spec", NON_FATAL);
- X+ appt->flags |= A_COMMENT;
- X return(0);
- X }
- X *incl_ptr = '\0';
- X***************
- X*** 339,348
- X sprintf(incl_buf, "%s/%s", lib_dir, strbuf);
- X else
- X sprintf(incl_buf, "%s/%s", apts_dir, strbuf);
- X! if ((include = fopen(incl_buf, "r")) == NULL)
- X! err_rpt("can't open include file (ignored)", NON_FATAL);
- X! else
- X! including = 1;
- X }
- X appt->flags |= A_COMMENT;
- X return(0);
- X
- X--- 371,383 -----
- X sprintf(incl_buf, "%s/%s", lib_dir, strbuf);
- X else
- X sprintf(incl_buf, "%s/%s", apts_dir, strbuf);
- X! if ((include[include_level] = fopen(incl_buf, "r")) == NULL) {
- X! strcpy(errbuf, "can't open include file <");
- X! strcat(errbuf, incl_buf);
- X! strcat(errbuf, "> (ignored)");
- X! err_rpt(errbuf, NON_FATAL);
- X! } else
- X! include_level++;
- X }
- X appt->flags |= A_COMMENT;
- X return(0);
- X***************
- X*** 367,373
- X }
- X /* sanity check */
- X if (appt->year < 0) {
- X! err_rpt("illegal year value (ignored)", NON_FATAL);
- X return(1);
- X }
- X }
- X
- X--- 402,409 -----
- X }
- X /* sanity check */
- X if (appt->year < 0) {
- X! sprintf(errbuf, "illegal year value [%d] (ignored)", appt->year);
- X! err_rpt(errbuf, NON_FATAL);
- X return(1);
- X }
- X }
- X***************
- X*** 383,389
- X if (one_based) (appt->month)--;
- X /* sanity check */
- X if (appt->month < JAN || appt->month > DEC) {
- X- /*
- X sprintf(errbuf, "illegal month value [%d] (ignored)", appt->month);
- X err_rpt(errbuf, NON_FATAL);
- X */
- X
- X--- 419,424 -----
- X if (one_based) (appt->month)--;
- X /* sanity check */
- X if (appt->month < JAN || appt->month > DEC) {
- X sprintf(errbuf, "illegal month value [%d] (ignored)", appt->month);
- X err_rpt(errbuf, NON_FATAL);
- X return(1);
- X***************
- X*** 386,393
- X /*
- X sprintf(errbuf, "illegal month value [%d] (ignored)", appt->month);
- X err_rpt(errbuf, NON_FATAL);
- X- */
- X- err_rpt("illegal month value (ignored)", NON_FATAL);
- X return(1);
- X }
- X }
- X
- X--- 421,426 -----
- X if (appt->month < JAN || appt->month > DEC) {
- X sprintf(errbuf, "illegal month value [%d] (ignored)", appt->month);
- X err_rpt(errbuf, NON_FATAL);
- X return(1);
- X }
- X }
- X***************
- X*** 405,411
- X if (!one_based) (appt->day)++;
- X /* sanity check */
- X if (appt->day < 1 || appt->day > 31) {
- X! err_rpt("illegal day value (ignored)", NON_FATAL);
- X return(1);
- X }
- X } else {
- X
- X--- 438,445 -----
- X if (!one_based) (appt->day)++;
- X /* sanity check */
- X if (appt->day < 1 || appt->day > 31) {
- X! sprintf(errbuf, "illegal day value [%d] (ignored)", appt->day);
- X! err_rpt(errbuf, NON_FATAL);
- X return(1);
- X }
- X } else {
- X***************
- X*** 431,437
- X appt->flags |= EVERY_SAT;
- X else {
- X /* sanity check */
- X! err_rpt("illegal day name (ignored)", NON_FATAL);
- X return(1);
- X }
- X appt->day = 0;
- X
- X--- 465,472 -----
- X appt->flags |= EVERY_SAT;
- X else {
- X /* sanity check */
- X! sprintf(errbuf, "illegal day name [%s] (ignored)", wday);
- X! err_rpt(errbuf, NON_FATAL);
- X return(1);
- X }
- X appt->day = 0;
- X***************
- X*** 445,451
- X appt->hour += *++ptr - '0';
- X /* sanity check */
- X if (appt->hour < 0 || (appt->hour > 23 && appt->hour != 99)) {
- X! err_rpt("illegal hour value (ignored)", NON_FATAL);
- X return(1);
- X }
- X if ((version2 && appt->hour == 99) || (!version2 && appt->hour == 0))
- X
- X--- 480,487 -----
- X appt->hour += *++ptr - '0';
- X /* sanity check */
- X if (appt->hour < 0 || (appt->hour > 23 && appt->hour != 99)) {
- X! sprintf(errbuf, "illegal hour value [%d] (ignored)", appt->hour);
- X! err_rpt(errbuf, NON_FATAL);
- X return(1);
- X }
- X if ((version2 && appt->hour == 99) || (!version2 && appt->hour == 0))
- X***************
- X*** 460,466
- X /* minutes currently can only be 00 or 30
- X * unless it's a note.
- X */
- X! err_rpt("illegal minute value (ignored)", NON_FATAL);
- X return(1);
- X }
- X if ((appt->flags & A_NOTE) && version2 && appt->minute == 99)
- X
- X--- 496,503 -----
- X /* minutes currently can only be 00 or 30
- X * unless it's a note.
- X */
- X! sprintf(errbuf, "illegal minute value [%d] (ignored)", appt->minute);
- X! err_rpt(errbuf, NON_FATAL);
- X return(1);
- X }
- X if ((appt->flags & A_NOTE) && version2 && appt->minute == 99)
- X***************
- X*** 472,478
- X appt->arrows += *++ptr - '0';
- X /* sanity check */
- X if (appt->arrows < 0 || appt->arrows > N_TSLOTS) {
- X! err_rpt("illegal arrow value (ignored)", NON_FATAL);
- X return(1);
- X }
- X ++ptr;
- X
- X--- 509,516 -----
- X appt->arrows += *++ptr - '0';
- X /* sanity check */
- X if (appt->arrows < 0 || appt->arrows > N_TSLOTS) {
- X! sprintf(errbuf, "illegal arrow value [%d] (ignored)", appt->arrows);
- X! err_rpt(errbuf, NON_FATAL);
- X return(1);
- X }
- X ++ptr;
- X***************
- X*** 480,513
- X ++ptr;
- X /* lookahead and repeat entries are free format, i.e. they */
- X /* can occur in either order */
- X! if (*ptr == '[') {
- X! appt->flags |= REPEAT;
- X! if (appt->flags & EVERY_SOMEDAY) {
- X! if ((appt->repeat = do_wk_repeat(&ptr)) < 0)
- X! return(1);
- X! } else {
- X! if ((appt->repeat = do_repeat(&ptr)) < 0)
- X! return(1);
- X! }
- X! if (*ptr == '<') {
- X! appt->flags |= LOOKAHEAD;
- X! if ((appt->lookahead = do_lookahead(&ptr)) < 0)
- X! return(1);
- X! }
- X! if (*ptr == '#') {
- X! appt->flags |= DELETED;
- X! ++ptr;
- X! while (isspace(*ptr))
- X! ++ptr;
- X! }
- X! } else if (*ptr == '<') {
- X! appt->flags |= LOOKAHEAD;
- X! if ((appt->lookahead = do_lookahead(&ptr)) < 0)
- X! return(1);
- X! if (*ptr == '[') {
- X! appt->flags |= REPEAT;
- X! if (appt->flags & EVERY_SOMEDAY) {
- X! if ((appt->repeat = do_wk_repeat(&ptr)) < 0)
- X return(1);
- X } else {
- X if ((appt->repeat = do_repeat(&ptr)) < 0)
- X
- X--- 518,542 -----
- X ++ptr;
- X /* lookahead and repeat entries are free format, i.e. they */
- X /* can occur in either order */
- X! parse_options = TRUE;
- X! while (parse_options) {
- X! switch (*ptr) {
- X! case '[':
- X! /* repeating appointment */
- X! appt->flags |= REPEAT;
- X! if (appt->flags & EVERY_SOMEDAY) {
- X! if ((appt->repeat = do_wk_repeat(&ptr)) < 0)
- X! return(1);
- X! } else {
- X! if ((appt->repeat = do_repeat(&ptr)) < 0)
- X! return(1);
- X! }
- X! break;
- X!
- X! case '<':
- X! /* remind us ahead of time */
- X! appt->flags |= LOOKAHEAD;
- X! if ((appt->lookahead = do_lookahead(&ptr)) < 0)
- X return(1);
- X break;
- X
- X***************
- X*** 509,516
- X if (appt->flags & EVERY_SOMEDAY) {
- X if ((appt->repeat = do_wk_repeat(&ptr)) < 0)
- X return(1);
- X! } else {
- X! if ((appt->repeat = do_repeat(&ptr)) < 0)
- X return(1);
- X }
- X }
- X
- X--- 538,551 -----
- X appt->flags |= LOOKAHEAD;
- X if ((appt->lookahead = do_lookahead(&ptr)) < 0)
- X return(1);
- X! break;
- X!
- X! case '+':
- X! /* this appointment lasts for n days */
- X! appt->flags |= RUN;
- X! while (isdigit(*++ptr))
- X! appt->runlength = appt->runlength * 10 + (int)(*ptr - '0');
- X! if (appt->runlength < 0)
- X return(1);
- X if (!(appt->flags & REPEAT)) {
- X /* default to run of days */
- X***************
- X*** 512,523
- X } else {
- X if ((appt->repeat = do_repeat(&ptr)) < 0)
- X return(1);
- X! }
- X! }
- X! if (*ptr == '#') {
- X! appt->flags |= DELETED;
- X! ++ptr;
- X! while (isspace(*ptr))
- X ++ptr;
- X }
- X } else if (*ptr == '#') {
- X
- X--- 547,562 -----
- X appt->runlength = appt->runlength * 10 + (int)(*ptr - '0');
- X if (appt->runlength < 0)
- X return(1);
- X! if (!(appt->flags & REPEAT)) {
- X! /* default to run of days */
- X! appt->flags |= REPEAT;
- X! appt->repeat = 1;
- X! }
- X! break;
- X!
- X! case '#':
- X! /* deleted appointment */
- X! appt->flags |= DELETED;
- X ++ptr;
- X break;
- X
- X***************
- X*** 519,524
- X ++ptr;
- X while (isspace(*ptr))
- X ++ptr;
- X }
- X } else if (*ptr == '#') {
- X appt->flags |= DELETED;
- X
- X--- 558,568 -----
- X /* deleted appointment */
- X appt->flags |= DELETED;
- X ++ptr;
- X+ break;
- X+
- X+ default:
- X+ parse_options = FALSE;
- X+ break;
- X }
- X while (isspace(*ptr))
- X ++ptr;
- X***************
- X*** 520,528
- X while (isspace(*ptr))
- X ++ptr;
- X }
- X- } else if (*ptr == '#') {
- X- appt->flags |= DELETED;
- X- ++ptr;
- X while (isspace(*ptr))
- X ++ptr;
- X }
- X
- X--- 564,569 -----
- X parse_options = FALSE;
- X break;
- X }
- X while (isspace(*ptr))
- X ++ptr;
- X }
- X***************
- X*** 553,560
- X return(-1);
- X }
- X ++*ptr;
- X- while (isspace(**ptr))
- X- ++*ptr;
- X return(repeat);
- X }
- X
- X
- X--- 594,599 -----
- X return(-1);
- X }
- X ++*ptr;
- X return(repeat);
- X }
- X
- X***************
- X*** 584,592
- X return(-1);
- X }
- X ++*ptr;
- X- while (isspace(**ptr))
- X- ++*ptr;
- X-
- X return(repeat);
- X }
- X
- X
- X--- 623,628 -----
- X return(-1);
- X }
- X ++*ptr;
- X return(repeat);
- X }
- X
- X***************
- X*** 608,615
- X return(-1);
- X }
- X ++*ptr;
- X- while (isspace(**ptr))
- X- ++*ptr;
- X return(lookahead);
- X }
- X
- X
- X--- 644,649 -----
- X return(-1);
- X }
- X ++*ptr;
- X return(lookahead);
- X }
- X
- X***************
- X*** 687,692
- X
- X if (appt->flags & LOOKAHEAD)
- X fprintf(apts_file, "<%d> ", appt->lookahead);
- X if (appt->flags & DELETED)
- X fprintf(apts_file, "# %s\n", appt->str);
- X else
- X
- X--- 721,728 -----
- X
- X if (appt->flags & LOOKAHEAD)
- X fprintf(apts_file, "<%d> ", appt->lookahead);
- X+ if (appt->flags & RUN)
- X+ fprintf(apts_file, "+%d ", appt->runlength);
- X if (appt->flags & DELETED)
- X fprintf(apts_file, "# %s\n", appt->str);
- X else
- X***************
- X*** 726,731
- X return (rptstr);
- X }
- X
- X /*
- X * Print today's appointments to stdout or mail (useful if we only have an ASCII
- X * terminal connected to our Sun). Invoked by the "-p", "-P" or "-m" options.
- X
- X--- 762,768 -----
- X return (rptstr);
- X }
- X
- X+ #ifndef CALENCHECK
- X /*
- X * Print today's appointments to stdout or mail (useful if we only have an ASCII
- X * terminal connected to our Sun). Invoked by the "-p", "-P", "-m" or
- X***************
- X*** 728,734
- X
- X /*
- X * Print today's appointments to stdout or mail (useful if we only have an ASCII
- X! * terminal connected to our Sun). Invoked by the "-p", "-P" or "-m" options.
- X * Month information is only printed as PostScript output.
- X */
- X print_apts(which, dest)
- X
- X--- 765,772 -----
- X #ifndef CALENCHECK
- X /*
- X * Print today's appointments to stdout or mail (useful if we only have an ASCII
- X! * terminal connected to our Sun). Invoked by the "-p", "-P", "-m" or
- X! * "-M" options.
- X * Month information is only printed as PostScript output.
- X */
- X print_apts(which, dest)
- X***************
- X*** 734,740
- X print_apts(which, dest)
- X int which, dest;
- X {
- X! int i;
- X FILE *output, *pfp, *popen();
- X char cmd[80], *name, *cuserid();
- X
- X
- X--- 772,778 -----
- X print_apts(which, dest)
- X int which, dest;
- X {
- X! int i, gd_rtn;
- X FILE *output, *pfp, *popen();
- X char cmd[80], *name, *cuserid();
- X
- X***************
- X*** 738,746
- X FILE *output, *pfp, *popen();
- X char cmd[80], *name, *cuserid();
- X
- X- if (dest == DST_MAIL)
- X- /* only mail one day's appts */
- X- which = PRI_DAY;
- X fix_current_day();
- X if ((which == PRI_DAY) && !get_day_appts())
- X return; /* nothing to show */
- X
- X--- 776,781 -----
- X FILE *output, *pfp, *popen();
- X char cmd[80], *name, *cuserid();
- X
- X fix_current_day();
- X gd_rtn = get_day_appts();
- X if (which == PRI_DAY && !gd_rtn)
- X***************
- X*** 742,748
- X /* only mail one day's appts */
- X which = PRI_DAY;
- X fix_current_day();
- X! if ((which == PRI_DAY) && !get_day_appts())
- X return; /* nothing to show */
- X if (dest == DST_MAIL) {
- X if (mailto != NULL) {
- X
- X--- 777,784 -----
- X char cmd[80], *name, *cuserid();
- X
- X fix_current_day();
- X! gd_rtn = get_day_appts();
- X! if (which == PRI_DAY && !gd_rtn)
- X return; /* nothing to show */
- X if (which == PRI_DAY_XNOTES && gd_rtn == SOME_MKNOTES)
- X /* all we have is marked notes */
- X***************
- X*** 744,749
- X fix_current_day();
- X if ((which == PRI_DAY) && !get_day_appts())
- X return; /* nothing to show */
- X if (dest == DST_MAIL) {
- X if (mailto != NULL) {
- X name = mailto;
- X
- X--- 780,788 -----
- X gd_rtn = get_day_appts();
- X if (which == PRI_DAY && !gd_rtn)
- X return; /* nothing to show */
- X+ if (which == PRI_DAY_XNOTES && gd_rtn == SOME_MKNOTES)
- X+ /* all we have is marked notes */
- X+ return; /* nothing to show */
- X if (dest == DST_MAIL) {
- X if (mailto != NULL) {
- X name = mailto;
- X***************
- X*** 750,756
- X } else if ((name = cuserid(NULL)) == NULL) {
- X err_rpt("nobody to mail to", FATAL);
- X }
- X! sprintf(cmd, "mail -s \"Appointments for today\" %s", name);
- X if ((output = popen(cmd, "w")) == NULL)
- X err_rpt("Couldn't pipe to 'mail'", FATAL);
- X } else {
- X
- X--- 789,795 -----
- X } else if ((name = cuserid(NULL)) == NULL) {
- X err_rpt("nobody to mail to", FATAL);
- X }
- X! sprintf(cmd, "%s -s \"Appointments for today\" %s", MAILPROG, name);
- X if ((output = popen(cmd, "w")) == NULL)
- X err_rpt("Couldn't pipe to 'mail'", FATAL);
- X } else {
- X***************
- X*** 758,764
- X }
- X
- X if (which == PRI_DAY || which == PRI_DAY_XNOTES) {
- X! print_one_day(which, output);
- X } else if (which == PRI_WEEK || which == PRI_WEEK_XNOTES) {
- X current.tm_mday -= current.tm_wday; /* Sunday of this week */
- X fix_current_day();
- X
- X--- 797,803 -----
- X }
- X
- X if (which == PRI_DAY || which == PRI_DAY_XNOTES) {
- X! print_one_day(which, output, gd_rtn);
- X } else if (which == PRI_WEEK || which == PRI_WEEK_XNOTES) {
- X current.tm_mday -= current.tm_wday; /* Sunday of this week */
- X fix_current_day();
- X***************
- X*** 762,768
- X } else if (which == PRI_WEEK || which == PRI_WEEK_XNOTES) {
- X current.tm_mday -= current.tm_wday; /* Sunday of this week */
- X fix_current_day();
- X! if (nr_weekdays < 7) {
- X current.tm_mday++;
- X fix_current_day();
- X }
- X
- X--- 801,807 -----
- X } else if (which == PRI_WEEK || which == PRI_WEEK_XNOTES) {
- X current.tm_mday -= current.tm_wday; /* Sunday of this week */
- X fix_current_day();
- X! if (nr_weekdays < 7 || monday_first) {
- X current.tm_mday++;
- X fix_current_day();
- X }
- X***************
- X*** 767,774
- X fix_current_day();
- X }
- X for (i=0;i<nr_weekdays;i++) {
- X! if (get_day_appts())
- X! print_one_day(which, output);
- X current.tm_mday++;
- X fix_current_day();
- X }
- X
- X--- 806,814 -----
- X fix_current_day();
- X }
- X for (i=0;i<nr_weekdays;i++) {
- X! gd_rtn = get_day_appts();
- X! if ((gd_rtn && which == PRI_WEEK) || (gd_rtn & ~SOME_MKNOTES && which == PRI_WEEK_XNOTES))
- X! print_one_day(which, output, gd_rtn);
- X current.tm_mday++;
- X fix_current_day();
- X }
- X***************
- X*** 780,786
- X pclose(output);
- X }
- X
- X! print_one_day(which, output)
- X int which;
- X FILE *output;
- X {
- X
- X--- 820,826 -----
- X pclose(output);
- X }
- X
- X! print_one_day(which, output, gdrtn)
- X int which;
- X FILE *output;
- X int gdrtn;
- X***************
- X*** 783,788
- X print_one_day(which, output)
- X int which;
- X FILE *output;
- X {
- X int i;
- X struct appt_entry tmp_apt;
- X
- X--- 823,829 -----
- X print_one_day(which, output, gdrtn)
- X int which;
- X FILE *output;
- X+ int gdrtn;
- X {
- X int i;
- X struct appt_entry tmp_apt;
- X***************
- X*** 788,796
- X struct appt_entry tmp_apt;
- X char *format_appt();
- X
- X! fprintf(output,"\n\t*** Appointments for %s %s %d, %d ***\n\n",
- X! daynames[current.tm_wday], monthnames[current.tm_mon],
- X! current.tm_mday, current.tm_year+1900);
- X
- X for (i=0; i<N_SLOTS; i++) {
- X if (i == n_tslots)
- X
- X--- 829,842 -----
- X struct appt_entry tmp_apt;
- X char *format_appt();
- X
- X! if (day_first)
- X! fprintf(output,"\n\t*** Appointments for %s %d %s %d ***\n\n",
- X! daynames[current.tm_wday], current.tm_mday,
- X! monthnames[current.tm_mon], current.tm_year+1900);
- X! else
- X! fprintf(output,"\n\t*** Appointments for %s %s %d, %d ***\n\n",
- X! daynames[current.tm_wday], monthnames[current.tm_mon],
- X! current.tm_mday, current.tm_year+1900);
- X
- X for (i=0; i<N_SLOTS; i++) {
- X if (i == n_tslots)
- X***************
- X*** 795,801
- X for (i=0; i<N_SLOTS; i++) {
- X if (i == n_tslots)
- X /* start of notes section */
- X! fprintf(output,"\n\t\t ===== Notes =====\n");
- X if (slots[i].first != NULL && slots[i].count > 0) {
- X /* at least one appt here */
- X slots[i].cur_appt = slots[i].first;
- X
- X--- 841,849 -----
- X for (i=0; i<N_SLOTS; i++) {
- X if (i == n_tslots)
- X /* start of notes section */
- X! if ((gdrtn & SOME_NOTES) ||
- X! (!(which & PRI_XNOTES) && (gdrtn & SOME_MKNOTES)))
- X! fprintf(output,"\n\t\t ===== Notes =====\n");
- X if (slots[i].first != NULL && slots[i].count > 0) {
- X /* at least one appt here */
- X slots[i].cur_appt = slots[i].first;
- X***************
- X*** 841,847
- X * also support a "lookahead" reminder service to remind one
- X * in advance of a future appointment.
- X * If "save_old" is set, then any appointments for years prior
- X! * to this one are save in a special file of the form
- X * ".appointments.YY", where YY is the year.
- X */
- X
- X
- X--- 889,895 -----
- X * also support a "lookahead" reminder service to remind one
- X * in advance of a future appointment.
- X * If "save_old" is set, then any appointments for years prior
- X! * to this one are saved in a special file of the form
- X * ".appointments.YY", where YY is the year.
- X */
- X
- X***************
- X*** 864,870
- X
- X /* copy existing entries to the new file */
- X save_base = one_based;
- X! while ((err_flag = get_aentry(oappts, &appt)) != EOF) {
- X if (err_flag)
- X continue; /* ignore badly formatted input */
- X if (appt.hour == 0)
- X
- X--- 912,918 -----
- X
- X /* copy existing entries to the new file */
- X save_base = one_based;
- X! while ((err_flag = get_aentry(oappts, &appt, TRUE)) != EOF) {
- X if (err_flag)
- X continue; /* ignore badly formatted input */
- X if (appt.hour == 0)
- X***************
- X*** 891,898
- X fclose(fp);
- X }
- X } else {
- X! if (put_aentry(nappts, &appt))
- X! err_rpt("write to new appt file failed, bailing out", FATAL);
- X }
- X one_based = save_base; /* (maybe) force old format input */
- X }
- X
- X--- 939,949 -----
- X fclose(fp);
- X }
- X } else {
- X! if (appt.flags & A_COMMENT)
- X! fputs(inbuf, nappts);
- X! else
- X! if (put_aentry(nappts, &appt))
- X! err_rpt("write to new appt file failed, bailing out", FATAL);
- X }
- X one_based = save_base; /* (maybe) force old format input */
- X }
- X***************
- X*** 904,971
- X }
- X
- X /*
- X- * Scan appointments file for outdated appointments and save them to a
- X- * special file of the form ".appointments.YY", where YY is the year
- X- * of that appointment.
- X- */
- X- create_old_files()
- X- {
- X- FILE *oappts, *nappts, *fp;
- X- struct appt_entry appt;
- X- int err_flag;
- X- char save_file[128];
- X- struct stat stbuf;
- X-
- X- if (read_only != 0) {
- X- err_rpt("appts file is read-only, no conversion done", NON_FATAL);
- X- return;
- X- }
- X-
- X- /* open files, etc */
- X- if ((oappts = fopen(apts_pathname, "r")) == NULL) {
- X- err_rpt("can't open appts file for reading", FATAL);
- X- /* NOT REACHED */
- X- }
- X- if ((nappts = fopen(tmpapts_pathname, "w")) == NULL) {
- X- err_rpt("can't open temp file for writing", NON_FATAL);
- X- return;
- X- }
- X-
- X- /* copy existing entries to the tmp file, checking dates */
- X- while ((err_flag = get_aentry(oappts, &appt)) != EOF) {
- X- if (err_flag)
- X- continue; /* ignore badly formatted input */
- X- if (!(appt.flags & A_COMMENT)
- X- && !(appt.flags & ALL_YEARS) && (appt.year < today.tm_year)
- X- && !((appt.flags & REPEAT) && !(appt.flags & EVERY_SOMEDAY))) {
- X- /* prepend directory info */
- X- sprintf(save_file, "%s/.appointments.%02d",
- X- apts_dir, appt.year);
- X- if (stat(save_file, &stbuf) && errno == ENOENT) {
- X- /* new file*/
- X- if ((fp = fopen(save_file, "w")) == NULL)
- X- err_rpt("can't open save file, bailing out", FATAL);
- X- fputs(HEADER, fp);
- X- fclose(fp);
- X- }
- X- if ((fp = fopen(save_file, "a+")) == NULL)
- X- err_rpt("can't open save file, bailing out", FATAL);
- X- else {
- X- if (put_aentry(fp, &appt))
- X- err_rpt("write to save appt file failed, bailing out", FATAL);
- X- fclose(fp);
- X- }
- X- } else {
- X- if (put_aentry(nappts, &appt))
- X- err_rpt("write to new appt file failed, bailing out", FATAL);
- X- }
- X- }
- X- fclose(oappts);
- X- fclose(nappts);
- X- xrename(tmpapts_pathname, apts_pathname);
- X- }
- X-
- X- /*
- X * convert appt entry to ASCII string for display with date, time and msg
- X */
- X char *
- X
- X--- 955,960 -----
- X }
- X
- X /*
- X * convert appt entry to ASCII string for display with date, time and msg
- X */
- X char *
- X***************
- X*** 997,1005
- X if (appt->flags & A_NOTE) {
- X /* note */
- X if (appt->flags & ALL_YEARS)
- X! sprintf(strbuf,"%3.3s %2d/%02d -- %s",
- X! daynames[current.tm_wday], appt->month+1,
- X! appt->day, appt->str);
- X else if (appt->year > 99)
- X sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %s",
- X daynames[current.tm_wday], appt->month+1,
- X
- X--- 986,999 -----
- X if (appt->flags & A_NOTE) {
- X /* note */
- X if (appt->flags & ALL_YEARS)
- X! if (day_first)
- X! sprintf(strbuf,"%3.3s %2d/%02d -- %s",
- X! daynames[current.tm_wday], appt->day,
- X! appt->month+1, appt->str);
- X! else
- X! sprintf(strbuf,"%3.3s %2d/%02d -- %s",
- X! daynames[current.tm_wday], appt->month+1,
- X! appt->day, appt->str);
- X else if (appt->year > 99)
- X if (day_first)
- X sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %s",
- X***************
- X*** 1001,1009
- X daynames[current.tm_wday], appt->month+1,
- X appt->day, appt->str);
- X else if (appt->year > 99)
- X! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %s",
- X! daynames[current.tm_wday], appt->month+1,
- X! appt->day, appt->year-100, appt->str);
- X else
- X sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %s",
- X daynames[current.tm_wday], appt->month+1,
- X
- X--- 995,1008 -----
- X daynames[current.tm_wday], appt->month+1,
- X appt->day, appt->str);
- X else if (appt->year > 99)
- X! if (day_first)
- X! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %s",
- X! daynames[current.tm_wday], appt->day,
- X! appt->month+1, appt->year-100, appt->str);
- X! else
- X! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %s",
- X! daynames[current.tm_wday], appt->month+1,
- X! appt->day, appt->year-100, appt->str);
- X else
- X if (day_first)
- X sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %s",
- X***************
- X*** 1005,1014
- X daynames[current.tm_wday], appt->month+1,
- X appt->day, appt->year-100, appt->str);
- X else
- X! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %s",
- X! daynames[current.tm_wday], appt->month+1,
- X! appt->day, appt->year, appt->str);
- X! } else
- X /* standard appointment */
- X sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d to %2d:%02d %s",
- X daynames[current.tm_wday], appt->month+1,
- X
- X--- 1004,1018 -----
- X daynames[current.tm_wday], appt->month+1,
- X appt->day, appt->year-100, appt->str);
- X else
- X! if (day_first)
- X! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %s",
- X! daynames[current.tm_wday], appt->day,
- X! appt->month+1, appt->year, appt->str);
- X! else
- X! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %s",
- X! daynames[current.tm_wday], appt->month+1,
- X! appt->day, appt->year, appt->str);
- X! } else {
- X /* standard appointment */
- X if (hour24)
- X if (day_first)
- X***************
- X*** 1010,1020
- X appt->day, appt->year, appt->str);
- X } else
- X /* standard appointment */
- X! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d to %2d:%02d %s",
- X! daynames[current.tm_wday], appt->month+1,
- X! appt->day, appt->year, appt->hour, appt->minute,
- X! e_hour, e_minutes, appt->str);
- X!
- X current = Save;
- X return(strbuf);
- X }
- X
- X--- 1014,1048 -----
- X appt->day, appt->year, appt->str);
- X } else {
- X /* standard appointment */
- X! if (hour24)
- X! if (day_first)
- X! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d to %2d:%02d %s",
- X! daynames[current.tm_wday], appt->day,
- X! appt->month+1, appt->year, appt->hour, appt->minute,
- X! e_hour, e_minutes, appt->str);
- X! else
- X! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d to %2d:%02d %s",
- X! daynames[current.tm_wday], appt->month+1,
- X! appt->day, appt->year, appt->hour, appt->minute,
- X! e_hour, e_minutes, appt->str);
- X! else
- X! if (day_first)
- X! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d%s to %2d:%02d%s %s",
- X! daynames[current.tm_wday], appt->day,
- X! appt->month+1, appt->year, (appt->hour < 13 ? appt->hour : appt->hour-12), appt->minute,
- X! (appt->hour < 12 ? "am" : "pm"),
- X! (e_hour < 13 ? e_hour : e_hour-12), e_minutes,
- X! (e_hour < 12 ? "am" : "pm"),
- X! appt->str);
- X! else
- X! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d%s to %2d:%02d%s %s",
- X! daynames[current.tm_wday], appt->month+1,
- X! appt->day, appt->year, (appt->hour < 13 ? appt->hour : appt->hour-12), appt->minute,
- X! (appt->hour < 12 ? "am" : "pm"),
- X! (e_hour < 13 ? e_hour : e_hour-12), e_minutes,
- X! (e_hour < 12 ? "am" : "pm"),
- X! appt->str);
- X! }
- X current = Save;
- X return(strbuf);
- X }
- X***************
- X*** 1046,1052
- X }
- X
- X strbuf[0] = '\0';
- X! if (!(appt->flags & A_NOTE))
- X /* standard appointment */
- X sprintf(strbuf,"%2d:%02d to %2d:%02d ",
- X appt->hour, appt->minute, e_hour, e_minutes);
- X
- X--- 1074,1080 -----
- X }
- X
- X strbuf[0] = '\0';
- X! if (!(appt->flags & A_NOTE)) {
- X /* standard appointment */
- X if (hour24)
- X sprintf(strbuf,"%2d:%02d to %2d:%02d ",
- X***************
- X*** 1048,1055
- X strbuf[0] = '\0';
- X if (!(appt->flags & A_NOTE))
- X /* standard appointment */
- X! sprintf(strbuf,"%2d:%02d to %2d:%02d ",
- X! appt->hour, appt->minute, e_hour, e_minutes);
- X p = appt->str;
- X q = strbuf + strlen(strbuf);
- X while (*p) {
- X
- X--- 1076,1091 -----
- X strbuf[0] = '\0';
- X if (!(appt->flags & A_NOTE)) {
- X /* standard appointment */
- X! if (hour24)
- X! sprintf(strbuf,"%2d:%02d to %2d:%02d ",
- X! appt->hour, appt->minute, e_hour, e_minutes);
- X! else
- X! sprintf(strbuf,"%2d:%02d%s to %2d:%02d%s ",
- X! (appt->hour < 13 ? appt->hour : appt->hour-12), appt->minute,
- X! (appt->hour < 12 ? "am" : "pm"),
- X! (e_hour < 13 ? e_hour : e_hour-12), e_minutes,
- X! (e_hour < 12 ? "am" : "pm"));
- X! }
- X p = appt->str;
- X q = strbuf + strlen(strbuf);
- X while (*p) {
- X***************
- X*** 1077,1083
- X }
- X
- X /*
- X! * parse the date on the given tring and reset the "current"
- X * date to reflect that date. The date may take the form of a
- X * day name (e.g. Tu, Tue, Tuesday) or a date in m/d/y format
- X * where the month and/or year may be missing (e.g. 27 = 27th
- X
- X--- 1113,1119 -----
- X }
- X
- X /*
- X! * parse the date on the given string and reset the "current"
- X * date to reflect that date. The date may take the form of a
- X * day name (e.g. Tu, Tue, Tuesday) or a date in m/d/y format
- X * where the month and/or year may be missing (e.g. 27 = 27th
- X***************
- X*** 1084,1089
- X * of this month, 8/27 = August 27 of this year, 8/27/89 =
- X * August 27 of 1989. If 'cmdline' is true, then the string
- X * came from the command line '-d' option.
- X */
- X int
- X parse_date(str, cmdline)
- X
- X--- 1120,1128 -----
- X * of this month, 8/27 = August 27 of this year, 8/27/89 =
- X * August 27 of 1989. If 'cmdline' is true, then the string
- X * came from the command line '-d' option.
- X+ * If the first character of the date is + or - scan the number and
- X+ * use it as an offset in days from the current date. Thus -1 becomes
- X+ * yesterday and +1 becomes tomorrow. pbm.
- X */
- X int
- X parse_date(str, cmdline)
- X***************
- X*** 1125,1134
- X }
- X if (y > 0)
- X current.tm_year = y;
- X! if (m > 0)
- X! current.tm_mon = m - 1;
- X! if (d > 0)
- X! current.tm_mday = d;
- X fix_current_day();
- X } else {
- X /* day of week */
- X
- X--- 1164,1182 -----
- X }
- X if (y > 0)
- X current.tm_year = y;
- X! if (day_first) {
- X! if (m > 0) {
- X! current.tm_mon = d - 1;
- X! current.tm_mday = m;
- X! } else if (d > 0)
- X! current.tm_mday = d;
- X! } else {
- X! if (m > 0) {
- X! current.tm_mon = m - 1;
- X! current.tm_mday = d;
- X! } else if (d > 0)
- X! current.tm_mday = d;
- X! }
- X fix_current_day();
- X } else if (*str == '-' || *str == '+') {
- X /*
- X***************
- X*** 1130,1135
- X if (d > 0)
- X current.tm_mday = d;
- X fix_current_day();
- X } else {
- X /* day of week */
- X /* check for day names */
- X
- X--- 1178,1193 -----
- X current.tm_mday = d;
- X }
- X fix_current_day();
- X+ } else if (*str == '-' || *str == '+') {
- X+ /*
- X+ * If the argument begins with a + or - assume that it is an
- X+ * offset in days from the current date. Use current date if the
- X+ * number doesn't scan after the - or +. pbm
- X+ */
- X+ if (sscanf(str, "%d", &i) == 1) {
- X+ current.tm_mday += i;
- X+ fix_current_day();
- X+ }
- X } else {
- X /* day of week */
- X /* check for day names */
- X***************
- X*** 1180,1186
- X
- X lock_cursors();
- X working(TRUE);
- X! sprintf(buf, "Appointments file \"%s\" printed for %s on %s", apts_pathname, cuserid(NULL), todays_date);
- X if (mainsw_state != DISPLAYING_MONTH) {
- X if ((fp = fopen(rasfile, "w")) != NULL) {
- X rect = (Rect *) window_get(canvas, WIN_RECT);
- X
- X--- 1238,1244 -----
- X
- X lock_cursors();
- X working(TRUE);
- X! sprintf(buf, "Appointments file \"%s\" printed for %s on %s", apts_pathname, cuserid(NULL), clockstr);
- X if (mainsw_state != DISPLAYING_MONTH) {
- X if ((fp = fopen(rasfile, "w")) != NULL) {
- X rect = (Rect *) window_get(canvas, WIN_RECT);
- X***************
- X*** 1217,1223
- X err_rpt("only PostScript output available for month printout", NON_FATAL);
- X } else {
- X if ((pfp = fopen(psfile, "w")) != NULL) {
- X! print_month(pfp, FALSE);
- X fclose(pfp);
- X sprintf(prntcmd, "%s %s", printer, psfile);
- X system(prntcmd);
- X
- X--- 1275,1281 -----
- X err_rpt("only PostScript output available for month printout", NON_FATAL);
- X } else {
- X if ((pfp = fopen(psfile, "w")) != NULL) {
- X! print_month(pfp, TRUE);
- X fclose(pfp);
- X sprintf(prntcmd, "%s %s", printer, psfile);
- X system(prntcmd);
- X***************
- X*** 1230,1235
- X unlock_cursors();
- X }
- X #endif /* NO_PRINTER */
- X
- X /* set error logging flag */
- X err2console(state)
- X
- X--- 1288,1294 -----
- X unlock_cursors();
- X }
- X #endif /* NO_PRINTER */
- X+ #endif /* CALENCHECK */
- X
- X /* set error logging flag */
- X err2console(state)
- X***************
- X*** 1252,1257
- X {
- X FILE *f;
- X int closed;
- X
- X closed = (int) window_get(frame, FRAME_CLOSED);
- X if (frame && !log_to_console && !closed) {
- X
- X--- 1311,1317 -----
- X {
- X FILE *f;
- X int closed;
- X+ char *getenv();
- X
- X #ifndef NOTOOL
- X closed = (int) window_get(frame, FRAME_CLOSED);
- X***************
- X*** 1253,1258
- X FILE *f;
- X int closed;
- X
- X closed = (int) window_get(frame, FRAME_CLOSED);
- X if (frame && !log_to_console && !closed) {
- X /* base frame exists */
- X
- X--- 1313,1319 -----
- X int closed;
- X char *getenv();
- X
- X+ #ifndef NOTOOL
- X closed = (int) window_get(frame, FRAME_CLOSED);
- X if (frame && !log_to_console && !closed) {
- X /* base frame exists */
- X***************
- X*** 1260,1265
- X (void) window_loop(prompt_frame);
- X window_set(prompt_frame, WIN_SHOW, FALSE, 0);
- X } else if ((f=fopen("/dev/console", "w")) != NULL) {
- X fprintf(f, "%s: %s\n", progname, errstr);
- X fclose(f);
- X } else
- X
- X--- 1321,1329 -----
- X (void) window_loop(prompt_frame);
- X window_set(prompt_frame, WIN_SHOW, FALSE, 0);
- X } else if ((f=fopen("/dev/console", "w")) != NULL) {
- X+ #else
- X+ if (getenv("WINDOW_PARENT") != NULL && (f=fopen("/dev/console", "w")) != NULL) {
- X+ #endif
- X fprintf(f, "%s: %s\n", progname, errstr);
- X fclose(f);
- X } else
- X***************
- X*** 1268,1273
- X exit(1);
- X }
- X
- X /* Clean-up */
- X cleanup()
- X {
- X
- X--- 1332,1338 -----
- X exit(1);
- X }
- X
- X+ #ifndef CALENCHECK
- X /* Clean-up */
- X cleanup()
- X {
- X***************
- X*** 1275,1282
- X close_day();
- X
- X /* create outdated include files (if necessary) */
- X! if (save_old)
- X! create_old_files();
- X
- X /* delete tmp file */
- X if (access(tmpapts_pathname, R_OK) == 0 && unlink(tmpapts_pathname) < 0)
- X
- X--- 1340,1347 -----
- X close_day();
- X
- X /* create outdated include files (if necessary) */
- X! if (save_old || expire_days)
- X! expire(expire_days);
- X
- X /* delete tmp file */
- X if (access(tmpapts_pathname, R_OK) == 0 && unlink(tmpapts_pathname) < 0)
- X***************
- X*** 1296,1298
- X err_rpt("couldn't rename/copy tmp file", NON_FATAL);
- X }
- X }
- X
- X--- 1361,1364 -----
- X err_rpt("couldn't rename/copy tmp file", NON_FATAL);
- X }
- X }
- X+ #endif /* CALENCHECK */
- X*** /tmp/,RCSt1a16998 Fri Dec 15 17:24:01 1989
- X--- version.c Fri Dec 15 17:18:34 1989
- X***************
- X*** 1,5
- X /*
- X! * $Header: version.c,v 2.5 89/09/19 06:09:07 billr Exp $
- X */
- X /*
- X * version.c - current version of calentool program
- X
- X--- 1,5 -----
- X /*
- X! * $Header: version.c,v 2.6 89/12/15 17:18:32 billr Exp $
- X */
- X /*
- X * version.c - current version of calentool program
- X***************
- X*** 24,27
- X * notice remains intact.
- X */
- X
- X! char version[] = "Calendar Tool V2.1p4";
- X
- X--- 24,27 -----
- X * notice remains intact.
- X */
- X
- X! char version[] = "Calendar Tool V2.1p5";
- X*** /tmp/,RCSt1a17003 Fri Dec 15 17:24:04 1989
- X--- wevent.c Fri Dec 15 17:18:37 1989
- X***************
- X*** 1,5
- X /*
- X! * $Header: wevent.c,v 2.1 89/05/09 14:19:57 billr Exp $
- X */
- X /*
- X * wevent.c
- X
- X--- 1,5 -----
- X /*
- X! * $Header: wevent.c,v 2.2 89/12/15 17:18:35 billr Exp $
- X */
- X /*
- X * wevent.c
- X***************
- X*** 36,41
- X #include "event.h"
- X
- X extern Frame prompt_frame;
- X
- X week_inputevent(canvas, event)
- X Canvas canvas;
- X
- X--- 36,42 -----
- X #include "event.h"
- X
- X extern Frame prompt_frame;
- X+ extern int monday_first;
- X
- X week_inputevent(canvas, event)
- X Canvas canvas;
- X***************
- X*** 84,89
- X return;
- X }
- X current.tm_mday -= current.tm_wday;
- X current.tm_mday += day_chosen_from_week;
- X fix_current_day();
- X if (nr_weekdays == 5) {
- X
- X--- 85,96 -----
- X return;
- X }
- X current.tm_mday -= current.tm_wday;
- X+ if (monday_first) {
- X+ if (current.tm_wday == SUN)
- X+ current.tm_mday -= 7;
- X+ if (nr_weekdays == 7)
- X+ current.tm_mday++;
- X+ }
- X current.tm_mday += day_chosen_from_week;
- X fix_current_day();
- X if (nr_weekdays < 7) {
- X***************
- X*** 86,92
- X current.tm_mday -= current.tm_wday;
- X current.tm_mday += day_chosen_from_week;
- X fix_current_day();
- X! if (nr_weekdays == 5) {
- X current.tm_mday++;
- X fix_current_day();
- X }
- X
- X--- 93,99 -----
- X }
- X current.tm_mday += day_chosen_from_week;
- X fix_current_day();
- X! if (nr_weekdays < 7) {
- X current.tm_mday++;
- X fix_current_day();
- X }
- END_OF_FILE
- if test 51460 -ne `wc -c <'patches05d'`; then
- echo shar: \"'patches05d'\" unpacked with wrong size!
- fi
- # end of 'patches05d'
- fi
- echo shar: End of archive 4 \(of 4\).
- cp /dev/null ark4isdone
- MISSING=""
- for I in 1 2 3 4 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 4 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
-